﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LinkyPOS.Class;

namespace LinkyPOS
{
    public partial class masrafRaporlari : Form
    {
        public masrafRaporlari()
        {
            InitializeComponent();
        }
        linkDataContext ly = new linkDataContext();
        kasa k = new kasa();
        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {

            monthCalendar1.Visible = false;
            monthCalendar2.Visible = false;
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {

            monthCalendar1.Visible = true;
            monthCalendar2.Visible = false;
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {

            monthCalendar1.Visible = true;
            monthCalendar2.Visible = true;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            lstMasraflar.Items.Clear();
            if (radioButton1.Checked)
            {// toplam
                List<masraflar> masr = k.toplamaaitmasraflar();
                foreach (var item in masr)
                {
                    ListViewItem lst = new ListViewItem();
                    lst.Text = item.tutari.ToString();
                    lst.SubItems.Add(item.turu.ToString());
                    lst.SubItems.Add(item.aciklama.ToString());
                    lst.SubItems.Add(item.tarih.ToString());

                    lstMasraflar.Items.Add(lst);
                }

            }
            else if (radioButton2.Checked)
            {// dönemsel
                List<masraflar> masr = k.donemaitmasraflar(Convert.ToDateTime(monthCalendar1.Text), Convert.ToDateTime(monthCalendar2.Text));
                foreach (var item in masr)
                {
                    ListViewItem lst = new ListViewItem();
                    lst.Text = item.tutari.ToString();
                    lst.SubItems.Add(item.turu.ToString());
                    lst.SubItems.Add(item.aciklama.ToString());
                    lst.SubItems.Add(item.tarih.ToString());

                    lstMasraflar.Items.Add(lst);
                }
            }
            else if (radioButton3.Checked)
            {// gün bazında
                List<masraflar> masr = k.guneaitmasraflar(Convert.ToDateTime(monthCalendar1.Text));
                foreach (var item in masr)
                {
                    ListViewItem lst = new ListViewItem();
                    lst.Text = item.tutari.ToString();
                    lst.SubItems.Add(item.turu.ToString());
                    lst.SubItems.Add(item.aciklama.ToString());
                    lst.SubItems.Add(item.tarih.ToString());

                    lstMasraflar.Items.Add(lst);
                }
            
            }
        }

        private void masrafRaporlari_Load(object sender, EventArgs e)
        {

        }
    }
}
